# This file should be sourced before call starman in any bashrc files!

export STARMAN_ROOT=$(cd $(dirname $BASH_SOURCE) && cd .. && pwd)
export PATH=$STARMAN_ROOT:$PATH

if [[ -d $STARMAN_ROOT/ruby/bin ]]; then
  export PATH=$STARMAN_ROOT/ruby/bin:$PATH
fi

function before_command {
  if [[ "$BASH_COMMAND" =~ .*starman[[:space:]]+(load) ]]; then
    res=$($BASH_COMMAND --print)
    if [[ ! "$res" =~ Warning && ! "$res" =~ Error ]]; then
      $(echo $res)
    fi
  fi
}
trap before_command DEBUG
